﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibGit2Sharp;

namespace SourceMaster.Model
{
    public class MyTag
    {
        public string CanoicalName { get; set; }
        public string Name { get; set; }
        public MyCommit Target { get; set; }
        public string TargetSha { get; set; }
        public bool IsAnnotated { get; set; }
        public bool HasCommitAsTarget { get; set; }
        public Tag OriginTag { get; set; }

        public static MyTag Create(LibGit2Sharp.Repository repo, LibGit2Sharp.Tag tag)
        {
            MyTag myTag = new MyTag
            {
                CanoicalName = tag.CanonicalName,
                Name = tag.Name,
                IsAnnotated = false,
                TargetSha = tag.Target.Sha,
                HasCommitAsTarget = tag.Target.GetType().FullName == "LibGit2Sharp.Commit",
                OriginTag = tag
            };
            return myTag;
        }
    }
}
